from rest_framework import serializers

from goods.models import Goods, GoodsCategory, SKU


class SKUDetailSerializer(serializers.ModelSerializer):

    class Meta:
        model=SKU
        fields=['id','name','price','default_image_url','comments']


class GoodsCategorySerializer(serializers.ModelSerializer):
    sku_set=SKUDetailSerializer(many=True)
    class Meta:
        model = GoodsCategory
        fields=['sku_set']
class SKUListSerializer(serializers.ModelSerializer):
    class Meta:
        model=SKU
        fields=['id','name','price','default_image_url','comments','create_time','price','sales']

from rest_framework import serializers
from goods.models import SKU

class HotsSkuSerializer(serializers.ModelSerializer):
    class Meta:
        model=SKU
        fields=['id','name','price','default_image_url','comments']
# class SKUListSerializer()
from goods.search_indexes import SKUIndex
from drf_haystack.serializers import HaystackSerializer

class SKUIndexSerializer(HaystackSerializer):
    """
    SKU索引结果数据序列化器
    """
    class Meta:
        index_classes = [SKUIndex]
        fields = ('text', 'id', 'name', 'price', 'default_image_url', 'comments')